﻿create procedure dbo.SaveAudienceMember
(
		@UserID int,
		@AudienceID int
	)

AS

	DECLARE @iCount int
	
	SET @iCount = (SELECT Count(UserId) FROM dbo.AudienceMembers WHERE UserID = @UserID AND AudienceID = @AudienceID)
	
	IF @iCount = 0
		BEGIN
			INSERT INTO dbo.AudienceMembers
			                      (UserID, AudienceId, CreatedOn)
			VALUES     (@UserID,@AudienceID, GETDATE())
		END
		
	RETURN


